package com.smiier.skin.net;

import java.util.ArrayList;

import android.content.Context;
import cn.o.app.io.INoProguard;
import cn.o.app.net.NetTask;

import com.smiier.skin.constant.Constant;
import com.smiier.skin.net.SysGetVerTask.SysGetVerRequest;
import com.smiier.skin.net.SysGetVerTask.SysGetVerResponse;
import com.smiier.skin.util.GlobalSettings;

/**
 * 获取版本号
 * 
 * @author 杨文华
 * 
 */
@SuppressWarnings("serial")
public class SysGetVerTask extends NetTask<SysGetVerRequest, SysGetVerResponse> {

	public static class SysGetVerRequest extends ORequest {
		public String appname = Constant.APP_NAME;
	}

	public static class SysGetVerResponse extends OResponse {
		public SysVerList Res;
	}

	public static class SysVerList extends ArrayList<SysVerItem> implements
			INoProguard {

	}

	public static class SysVerItem implements INoProguard {
		public String Name;
		public String Ver;
		public boolean Update;

		@Override
		public boolean equals(Object o) {
			if (this == o) {
				return true;
			}
			if (o == null) {
				return false;
			}
			if (this.getClass() != o.getClass()) {
				return false;
			}
			SysVerItem other = (SysVerItem) o;
			if (Name == null) {
				if (other.Name != null) {
					return false;
				}
			} else if (!Name.equals(other.Name)) {
				return false;
			}
			if (Ver == null) {
				if (other.Ver != null) {
					return false;
				}
			} else if (!Ver.equals(other.Ver)) {
				return false;
			}
			return true;
		}

	}

	@Override
	public void setContext(Context context) {
		super.setContext(context);
		mUrl = GlobalSettings.SERVER_URL + GlobalSettings.SERVER_URL_JOIN
				+ "?api=Sys.GetVer";
		mRequestMethod = METHOD_GET;
	}

}
